﻿using AutoMapper;
using MediatR;
using S.Eartag.API.Application.Command.MarkedConditionCommand;
using S.Eartag.Domain;
using S.Eartag.Domain.Model;
using S.Eartag.Infrastructure.Impl;
using S.Eartag.Infrastructure.Interface;

namespace S.Eartag.API.Application.CommandHandlers.MarkedConditionCommandHandler
{
    public class MarkedConditionCreateCommandHandler : IRequestHandler<MarkedConditionCreateCommand, int>
    {
        private readonly IMarkRepository markRepository;
        private readonly IMapper mapper;
        private readonly ILamBingRepository lamBingRepository;
        public MarkedConditionCreateCommandHandler(IMarkRepository markRepository, IMapper mapper, ILamBingRepository lamBingRepository)
        {
            this.markRepository = markRepository;
            this.mapper = mapper;
            this.lamBingRepository = lamBingRepository;
        }

        public async Task<int> Handle(MarkedConditionCreateCommand request, CancellationToken cancellationToken)
        {
            
            request.CreateBy = "张三";
            request.CreateDate = DateTime.Now;
            request.UpdateBy = null;
            request.UpdateDate = null;

            

            return await markRepository.Create(mapper.Map<Mark>(request));
        }   
    }
}
